def fac(n):
    res = 1
    i = 1
    while i<=n:
        res *= i
        i +=1
    return res
def sum(i,k):
    res01=0
    while i <= k:
        res01 += fac(i)
        i +=3
    return res01
result = sum(1,50)
print(result)